package com.cbl.v.ssczs.view.fragment;


import android.annotation.SuppressLint;
import android.graphics.Color;
import android.support.v4.app.Fragment;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.view.ViewGroup;
import android.widget.LinearLayout;
import android.widget.TextView;

import com.cbl.v.ssczs.R;
import com.cbl.v.ssczs.mode.util.DialogUtils;
import com.cbl.v.ssczs.view.agent.Html5WebView;

/**
 * A simple {@link Fragment} subclass.
 */
public class KJFragment1 extends BaseFragment {
    private LinearLayout mLayout;
    private Html5WebView mWebView;


    @Override
    protected int getLayout() {
        return R.layout.fragment_agentweb;
    }

    @SuppressLint("AddJavascriptInterface")
    @Override
    protected void initView(View view) {
        mLayout = (LinearLayout) view.findViewById(R.id.web_layout);
        LinearLayout.LayoutParams params = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup
                .LayoutParams
                .MATCH_PARENT);
        mWebView = new Html5WebView(getContext());
        mWebView.setLayoutParams(params);
        mWebView.setLayoutParams(params);
        mWebView.loadUrl("http://m.500.com/datachart/ssc/zx/jb.html");
        //mWebView.loadUrl("http://m.500.com/info/kaijiang/#h5");
        //mWebView.loadUrl("https://ic.snssdk.com/vertical/caipiao/report/");
        mLayout.addView(mWebView);
        mWebView.addJavascriptInterface(getActivity(), "android");
        initToolBar(view);
    }
    private void initToolBar(View view) {
        Toolbar toolBar = (Toolbar) view.findViewById(R.id.toolbar);
        TextView title_name = (TextView) view.findViewById(R.id.title_name);
        title_name.setText("重庆时时彩开奖走势");
        toolBar.setTitle("");
        toolBar.setTitleTextColor(Color.WHITE);
    }

    @Override
    protected void initData() {

    }

    @Override
    protected void initListener() {

    }


    @Override
    protected void onMyOnclick(View view) {

    }

    @Override
    public void finishBack() {
        DialogUtils.disMissDialog();
        super.finishBack();
    }


    @Override
    public void onDestroy() {
        if (mWebView != null) {
            mWebView.loadDataWithBaseURL(null, "", "text/html", "utf-8", null);
            mWebView.clearHistory();
            ((ViewGroup) mWebView.getParent()).removeView(mWebView);
            mWebView.destroy();
            mWebView = null;
        }
        super.onDestroy();
    }

}
